package xyz.zq.cloud.common.security.exception;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.springframework.http.HttpStatus;
import xyz.zq.cloud.common.security.component.CloudAuth2ExceptionSerializer;

/**
 * 未经授权的异常
 *
 * @author hzq
 * @date 2020/4/28 21:33
 */
@JsonSerialize(using = CloudAuth2ExceptionSerializer.class)
public class UnauthorizedException extends CloudAuth2Exception {
    public UnauthorizedException(String msg, Throwable t) {
        super(msg);
    }

    @Override
    public String getOAuth2ErrorCode() {
        return "unauthorized";
    }

    @Override
    public int getHttpErrorCode() {
        return HttpStatus.UNAUTHORIZED.value();
    }
}
